package servlet;

import entity.OrderInfo;
import service.OrderInfoService;
import service.OrdersService;
import service.impl.OrderInfoServiceImpl;
import service.impl.OrdersServiceImpl;
import vo.OrderInfoVo;
import vo.OrdersVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/OrderInfoServlet")
public class OrderInfoServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置编码
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        //定义session对象
        HttpSession session = request.getSession();
        //创建Writer对象
        PrintWriter out = response.getWriter();
        //id
        int id = Integer.parseInt(request.getParameter("id"));

        OrdersService service=new OrdersServiceImpl();
        OrdersVo ordersVo = service.selectOne(id);
        request.setAttribute("ordersVo",ordersVo);
        OrderInfoService service1=new OrderInfoServiceImpl();
        List<OrderInfoVo> orderInfoVo = service1.selectAll(id);
        request.setAttribute("orderInfoVo",orderInfoVo);
        request.getRequestDispatcher("order_detail.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
